package com.weilai.dao;

import com.weilai.domain.PrivateMessage;
import com.weilai.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PrivateMessageDao {

    //查询私信
    @Select("SELECT \n" +
            "    id, content, sender_id, receiver_id, created_at\n" +
            "FROM \n" +
            "    private_message \n" +
            "WHERE \n" +
            "    (sender_id = #{senderId} AND receiver_id = #{receiverId})\n" +
            "    and (sender_id = #{receiverId} AND receiver_id = #{senderId})\n" +
            "ORDER BY \n" +
            "    created_at DESC;")
    public List<PrivateMessage> getAllMessages(String senderId, String receiverId);

}
